{% extends  'admin/layout.html' %}
{% block css %}
<style>
            #auth_list .col-md-12,#auth_list .col-md-2{
            padding:0px;
        }
</style>
{% endblock %}
{% block content %}
        <section class="content-header">
            <h1>微电影管理系统</h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 角色管理</a></li>
                <li class="active">修改角色</li>
            </ol>
        </section>
        <section class="content" id="showcontent">
            <div class="row">
                <div class="col-md-12">
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">修改角色</h3>
                        </div>
                        {% include 'admin/flash_msg.html' %}
                        <form role="form" method="post">
                            <div class="box-body">
                                <div class="form-group">
                                    <label for="input_name">角色名称</label>
                                    <input type="text" class="form-control" id="input_name" placeholder="请输入角色名称！"  name="name" value="{{role.name|default('',True)}}">
                                     {% for err in form.name.errors %}
                              <div class="col-md-12">
                                <span style="color:red">{{ err }}</span>
                             </div>
                            {% endfor %}
                                </div>
                                <div class="form-group" id="auth_list">
                                    <div class="col-md-12">
                                        <label>操作权限</label>
                                    </div>
                                    <select name="auths" id="" multiple="multiple" class="form-control">
                                        {%  for auth in auths %}
                                        {% if auth.id in role.auths %}
                                            {{ auth.id }}
                                            {{ role.auths    }}
                                        <option value="{{ auth.id }}" selected="selected">{{ auth.name }}</option>
                                            {% else %}
                                        <option value="{{ auth.id }}">{{ auth.name }}</option>
                                            {% endif %}
                                        {% endfor %}
                                    </select>

                                </div>
                               {% for err in form.auths.errors %}
                              <div class="col-md-12">
                                <span style="color:red">{{ err }}</span>
                             </div>
                            {% endfor %}
                            </div>
                            <div class="box-footer">
                                {{ form.csrf_token }}
                                <button type="submit" class="btn btn-primary">添加</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </section>
{% endblock %}
{% block script %}
<script>
    $(function () {
        $('#g-10').addClass('active');
        $('#g-10-1').addClass('active')
    })
</script>
{% endblock %}